<template>
	<view class="stu_info_content">
		<view class="stu_info_list">
			<view class="stu_info_item">
				<view>Student Name：</view>
				<view>{{stuData.userName}}</view>
			</view>
			<view class="stu_info_item">
				<view>Chinese Mobile：</view>
				<view>{{stuData.stuPhoneHome}}</view>
			</view>
			<view class="stu_info_item">
				<view>Australian Mobile：</view>
				<view>{{stuData.stuPhoneAbord}}</view>
			</view>
			<view class="stu_info_item">
				<view>Email：</view>
				<view>{{stuData.stuEmail}}</view>
			</view>
			<view class="stu_info_item">
				<view>Service Duration：</view>
				<view>{{stuData.stuServiceBeginDate}} - {{stuData.stuServiceEndDate}}</view>
			</view>
			<view class="stu_info_item">
				<view>Parent Information：</view>
				<view>{{stuData.parentName}}</view>
			</view>
			<view class="stu_info_item">
				<view>Parent Mobile：</view>
				<view>{{stuData.fatherPhone}}</view>
			</view>
			<view class="stu_info_item">
				<view>Parent Email：</view>
				<view>{{stuData.parentEmail }}</view>
			</view>
			<view class="stu_info_item">
				<view>Parent Type：</view>
				<view>{{stuData.parentRole}}</view>
			</view>
			 
		</view>
		<view style="margin-top: 45px;">
			<button class="stu_btn" @tap="createRecord(stuData)">Create Visit</button>
			<!-- <button class="stu_btn" @tap="getStuPosition(stuData.userId)">获取学生位置</button> -->
		</view>
	</view>
</template>

<script>
	import api from '../../api/otherApi.js'
	export default {
		data(){
			return {
				stuData: {},
				token: ''
			}
		},
		methods: {
			createRecord(item) {
				uni.navigateTo({
					url: `../record/interviewRecord?intId=${item.stuGurdianId}&stuId=${item.userId}`
				})
			},
			async getStuPosition(id) {
				let _this = this
				let data = await api.addPositionGet(`position/addPositionGet?stuId=${id}`, _this.token)
				console.log(data)
				if (data.head.status) {
					uni.showToast({
						title: 'Send Location!',
						icon: 'none',
						duration: 2000
					});
				} else {
					uni.showToast({
						title: data.head.msg,
						icon: 'none',
						duration: 2000
					});
				}
			}
		},
		async onLoad(options) {
			let _this = this
			uni.getStorage({
				key: 'token',
				success(res) {
					_this.token = res.data
				}
			})
			let data = await api.getStudentInfo(`user/getStu?userId=${options.id}`, _this.token)
			console.log(data)
			if (data.head.status) {
				_this.stuData = data.body
			} else {
				uni.showToast({
					title: data.head.msg,
					icon: 'none',
					duration: 2000
				});
			}
		}
	}
</script>

<style scoped>
	.stu_info_content {
		width: 100%;
		padding: 20px 30px;
		box-sizing: border-box;
	}
	
	.stu_info_item {
		display: flex;
		justify-content: flex-start;
		padding: 15px 0;
		box-sizing: border-box;
		border-bottom: solid 1px #dfdfdf;
	}
	
	.stu_info_item view:first-child {
		margin-right: 15px;
		color: #666;
		font-size: 16px;
	}
	
	.stu_info_item view:last-child {
		color: #333;
		font-size: 16px;
	}
	
	.stu_btn {
		margin-top: 15px;
	}
</style>
